package com.yoda.mall.mysql;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author shawn
 * @date 2022年 12月 16日 0:58
 */
@MapperScan("com.yoda.mall.mysql.mapper")
@SpringBootApplication
@EnableTransactionManagement//开启事务管理
public class DubboSqlApplication {
    public static void main(String[] args) {
        SpringApplication.run(DubboSqlApplication.class,args);
    }
    /**
     * mybatis +拦截器
     * 分页插件
     * @return {@link MybatisPlusInterceptor}
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
